--隐于黑夜
local yinyuheiye = fk.CreateSkill {
    name = "mcdh_yinyuheiye"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

yinyuheiye:addEffect("viewas",{
    pattern = "peach",
    card_filter = function(self, to_select, selected)
        return #selected <= 2
    end,
    view_as = function(self, cards)
        if #cards ~= 2 then
            return nil
        end
        local c = Fk:cloneCard("peach")
        c.skillName = self.name
        c:addSubcards(cards)
        return c
    end,
    enabled_at_play = Util.FalseFunc,
    enabled_at_response = function(self, player, res)
        return player.phase == Player.NotActive and not res
    end
})

yinyuheiye:addEffect(fk.TurnEnd,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        local logic = room.logic
        if player:hasSkill(self) then
            local dying = logic:getEventsOfScope(GameEvent.Dying,1,function()return true end,Player.HistoryTurn)
            local death = logic:getEventsOfScope(GameEvent.Death,1,function()return true end,Player.HistoryTurn)
            return #dying > 0 and #death == 0
        end
    end,
    on_cost = function(self, event, target, player, data)
        return true
    end,
    on_use = function(self, event, target, player, data)
        lib.RecoverCharge(player,player,player:getMark("mcdh_charge_max")-player:getMark("mcdh_charge"))
    end
})

return yinyuheiye